package com.xzr.demo.controller;

import com.xzr.demo.entity.Userinfo;
import com.xzr.demo.service.UserService;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author：徐志荣
 * @Date：2023/6/20 上午 10:59
 */

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/getuserbyid")
    public Userinfo getUserById(Integer id){
        if(id == null) return null;
        return userService.getUserById(id);
    }

    @RequestMapping("/getAll")
    public List<Userinfo> getAll(){
     return userService.getAll();
    }

    @RequestMapping("/add")
    public  int add(Userinfo userinfo){
        return userService.add(userinfo);
    }

}
